package com.viewpagerindicator.sample.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.viewpagerindicator.sample.CutokApplication;
import com.viewpagerindicator.sample.R;
import com.viewpagerindicator.sample.util.URLs;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import cz.msebera.android.httpclient.Header;

/**
 * Created by zhao on 2015/11/22.
 */
public class CProgressDialog extends Dialog {

    Button okButton;
    CutokApplication application;
    public interface  LoginEventLinster{
        public void logineed(boolean isSuccess);
    }

    public LoginEventLinster loginEventLinster;
    public CProgressDialog(Context context, LoginEventLinster loginEventLinster) {
        super(context, R.style.LoginDialog);
        this.loginEventLinster=loginEventLinster;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.progress_dialog);
        setTitle(R.string.dialog_btn_search);
        application= (CutokApplication) getContext().getApplicationContext();
        okButton= (Button) findViewById(R.id.login_btn_ok);
        okButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
                loginEventLinster.logineed(true);
            }
        });
    }

    @Override
    public void show() {
        super.show();
        WindowManager windowManager = getWindow().getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        WindowManager.LayoutParams lp = this.getWindow().getAttributes();
        lp.width = (int)(display.getWidth())-40; //设置宽度
        this.getWindow().setAttributes(lp);
    }
}
